/*
 * uart.h
 *
 * Created: 12/17/2012 12:17:26 PM
 *  Author: duerk@msoe.edu <Kevin Duer>
 *			zimmermane@msoe.edu <Evan Zimmerman>
 *			woottons@msoe.edu <Scott Wootton>
 *	
 * 
 * Purpose: This is the header file for the uart
*/

#ifndef uart_h
#define uart_h

#include<stdint.h>
#define MAX_BUFFER_SIZE 40 // maximum input buffer size
volatile char line[MAX_BUFFER_SIZE]; //holds an entire line sent to the device.

/* uart_init
 * 
 * PURPOSE:
 *    Initializes the UART for sending and receiving data.
 *    The value to be written to URBRRL is passed in, and it
 *    is assumed that *only UBRRL needs to be written to.
 *    These values can be found in the Atmega32 reference
 *    manual. Initialized for synchronous communication
 *    and 8-bit characters.
 * PARAMS:
 *    uint8_t ubrrVal - value to be written to UBRRL
 * RETURNS:
 *    none
 */
void uart_init(uint8_t ubrrVal);

/* uart_putc
 * 
 * PURPOSE:
 *    Puts the specified character into the UDR to be
 *    sent out. If the char is a newline, it also sends
 *    out the return character.
 * PARAMS:
 *    char c - character to be written to the UDR
 * RETURNS:
 *    none
 */
void uart_putc(char c);

/* uart_getc
 * 
 * PURPOSE:
 *    Gets a character from the UDR and echos it back.
 *    The return character resets the buffer. If the char 
 *    is printable, it gets echoed back unless the buffer 
 *    is full, in which case a 'beep' char is sent.
 *    Backspace overwrites the previous char with a space
 *    and decrements the buffer write pointer.
 * PARAMS:
 *    none
 * RETURNS:
 *    char c - the character that was read
 */
char uart_getc(void);

#endif
